# make/common.mk
# Common variables and tasks for all platforms
# dart scripts/version_generator.dart
# --- Project Configuration (从 pubspec.yaml 动态获取) ---
APP_NAME := $(shell grep 'name:' pubspec.yaml | head -1 | awk '{print $$2}')
APP_VERSION := $(shell grep 'version:' pubspec.yaml | head -1 | awk '{print $$2}')

# --- Build Directories ---
BUILD_DIR := build

# --- Common Tasks ---
.PHONY: generate-version ync-version get clean doctor format analyze test



get:
	@echo "--> [COMMON] Fetching dependencies..."
	@flutter pub get

clean:
	@echo "--> [COMMON] Cleaning Flutter project..."
	@flutter clean

doctor:
	@echo "--> [COMMON] Running Flutter Doctor..."
	@flutter doctor -v

format:
	@echo "--> [COMMON] Formatting Dart code..."
	@dart format .

analyze:
	@echo "--> [COMMON] Analyzing Dart code..."
	@flutter analyze

test:
	@echo "--> [COMMON] Running tests..."
	@flutter test


#版本控制
.PHONY: generate-version sync-version
generate-version:
	dart scripts/version_generator.dart

sync-version:
	dart scripts/version_sync.dart $(PLATFORM_ARGS)

# 快捷命令（示例）
.PHONY: sync-android sync-ios sync-web sync-all
sync-android:
	$(MAKE) sync-version PLATFORM_ARGS="-a"

sync-ios:
	$(MAKE) sync-version PLATFORM_ARGS="-i"

sync-web:
	$(MAKE) sync-version PLATFORM_ARGS="-w"

sync-all:
	$(MAKE) sync-version PLATFORM_ARGS="-a -i -w"